package com.qing.transfomer.controller;

import com.alibaba.fastjson.JSONObject;
import com.qing.transfomer.dto.BaseRequestDTO;
import com.qing.transfomer.dto.order.GetOrderListRequestDTO;
import com.qing.transfomer.service.order.OderService;
import com.qing.transfomer.vo.BaseResponseVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Resource
    private OderService oderService;

    @GetMapping("/list/bubble")
    public BaseResponseVO<Integer> getOrderListBubble(
            @RequestHeader("baseUrl") String baseUrl,
            @RequestHeader("accessToken") String accessToken,
            @RequestHeader("code") String code) {
        BaseRequestDTO baseRequestDTO = new BaseRequestDTO();
        baseRequestDTO.setBaseUrl(baseUrl);
        baseRequestDTO.setAccessToken(accessToken);
        baseRequestDTO.setCode(code);
        return oderService.getOrderListBubble(baseRequestDTO);
    }

    @PostMapping("/list")
    public BaseResponseVO<List<JSONObject>> getOrderList(
            @RequestHeader("baseUrl") String baseUrl,
            @RequestHeader("accessToken") String accessToken,
            @RequestHeader("code") String code,
            @RequestBody GetOrderListRequestDTO getOrderListRequestDTO) {
        getOrderListRequestDTO.setBaseUrl(baseUrl);
        getOrderListRequestDTO.setAccessToken(accessToken);
        getOrderListRequestDTO.setCode(code);
        return oderService.getOrderList(getOrderListRequestDTO);
    }
}
